package project;
import java.sql.*;

public class MySQL_Connection 
{
	private String dbName, url, userID, psw, ipAddress;
	private Connection conn = null;
	Class registerDriver = null;
	
	public MySQL_Connection(String dbName,String ipAddress,
							String userID, String psw) 
							throws SQLException, ClassNotFoundException
	{
		this.dbName = dbName;
		this.userID = userID;
		this.psw = psw;
		this.ipAddress = ipAddress;
		this.url = "jdbc:mysql://"+ipAddress+"/"+dbName;
		
		Class.forName("com.mysql.jdbc.Driver");
		System.out.println("Driver.class registered "+
							"with DriverManager");
		//try
		//{
			conn = DriverManager.getConnection(url, userID, psw);
		//}
		//catch(Exception ex)
		//{
		//	throw new 
		//}
		System.out.println("Made connection to the "+dbName+" db...>>>");
		
	}//end of constructor
	
	public Connection getMySQLConnection()
	{
		return conn;
	}
	public void closeMySQLConnection() throws Exception
	{
		try
		{
			conn.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}
	public String getIPAddress()
	{
		return ipAddress;
	}
	public String getDBName()
	{
		return dbName;
	}
							
}
